home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3701 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.6 KB  |  55 lines

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Visual C++ 4.0 lacking initializers?
  5. Date: Thu, 25 Jan 1996 17:32:24 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4e8eqc$kue@news.halcyon.com>
  8. References: <31049C46.A26@oz.is>
  9. NNTP-Posting-Host: blv-pm11-ip18.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. I've never seen this attempted; where'd you learn to do this?
  13. The initializer list can do function calls, I guess, but I've only
  14. seen it used to call base-class and member-variable constructors,
  15. never to call another constructor for the class you're already
  16. constructing.
  17.  
  18. If you invoke the default Foo constructor, you want to first invoke
  19. the Foo::Foo(x) constructor with the value 10, then finish the default
  20. constructor.
  21.  
  22. How 'bout making a new, private method that does what you want
  23. Foo::Foo(x) to do, then have both the default and the (x) constructor
  24. call this abstraction?
  25.  
  26.                         --Norm 
  27.  
  28. Hßlfdan Ingvarsson <halfdan@oz.is> wrote:
  29.  
  30. >Is it me or is this sort of code not possible with VC++ 4.0? 
  31.  
  32. >// Declarations of class Foo
  33.  
  34. >// VC++ Complains about the line below with the error
  35. >// error C2436: '__ctor' : cannot initialize member functions
  36. >Foo::Foo(void) : Foo::Foo(10) {}
  37.  
  38. >Foo::Foo(x)
  39. >{
  40. >  // Some stuff
  41. >}
  42.  
  43. >Tell me about it,
  44.  
  45. >Ciao,
  46.  
  47. >  H.
  48.  
  49. >-- 
  50. >-------------------------------------------------------------------------------Halfdan Ingvarsson, Webmaster/Software Engineer, OZ/Snorrabraut 54/105 Iceland
  51. >WTel: +3545620362, WFax: +3545610362, HTel: +3545644424, E-Mail: halfdan@oz.is
  52. >HomePage: http://www.oz.is/~halfdan, ObQuote: Little things make big thing?
  53.  
  54.  
  55.